package com.markchu.modules.system.repository;

import com.markchu.common.constant.StatusConst;
import com.markchu.modules.system.domain.Upload;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author mark_chu
 * @date 2018/11/02
 */
public interface UploadRepository extends JpaRepository<Upload, Long> {

    /**
     * 查找指定文件sha1记录
     * @param sha1 文件sha1值
     * @return 文件信息
     */
    public Upload findBySha1(String sha1);

    @Modifying
    @Transactional
    @Query("update #{#entityName} set ac_id = ?1  where id in ?2")
    public void updateAcIdByUpload(Long acId, List<Long> fileId);

    @Modifying
    @Transactional
    @Query("update #{#entityName} set remark = ?1  where id = ?2")
    public void updateUpload(String remark,Long imgId);

    @Modifying
    @Transactional
    @Query("update #{#entityName} set status = ?1  where id = ?2")
    public void updateStatus(Long status,Long fileId);
}

